﻿using System.Reflection;

using WhereIsMyCash.IDAL;
using WhereIsMyCash.Config;

namespace WhereIsMyCash.DALFactory
{
    /// <summary>
    /// 数据库访问类提供程序
    /// </summary>
    public class DALProvider
    {
        /// <summary>
        /// 创建账户接口实例
        /// </summary>
        /// <returns></returns>
        public static IAccount CreateAccount()
        {
            return (IAccount)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.AccountDAL);
        }

        /// <summary>
        /// 创建银行卡接口实例
        /// </summary>
        /// <returns></returns>
        public static ICard CreateCard()
        {
            return (ICard)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.CardDAL);
        }

        /// <summary>
        /// 创建联系人接口实例
        /// </summary>
        /// <returns></returns>
        public static IContact CreateContact()
        {
            return (IContact)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.ContactDAL);
        }

        /// <summary>
        /// 创建联系人组接口实例
        /// </summary>
        /// <returns></returns>
        public static IContactGroup CreateContactGroup()
        {
            return (IContactGroup)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.ContactGroupDAL);
        }

        /// <summary>
        /// 创建支出接口实例
        /// </summary>
        /// <returns></returns>
        public static IExpenditure CreateExpenditure()
        {
            return (IExpenditure)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.ExpenditureDAL);
        }

        /// <summary>
        /// 创建支出明细接口实例
        /// </summary>
        /// <returns></returns>
        public static IExpenditureDetail CreateExpenditureDetail()
        {
            return (IExpenditureDetail)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.ExpenditureDetailDAL);
        }

        /// <summary>
        /// 创建支出类型接口实例
        /// </summary>
        /// <returns></returns>
        public static IExpenditureType CreateExpenditureType()
        {
            return (IExpenditureType)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.ExpenditureTypeDAL);
        }

        /// <summary>
        /// 创建收入接口实例
        /// </summary>
        /// <returns></returns>
        public static IIncome CreateIncome()
        {
            return (IIncome)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.IncomeDAL);
        }

        /// <summary>
        /// 创建收入明细接口实例
        /// </summary>
        /// <returns></returns>
        public static IIncomeDetail CreateIncomeDetail()
        {
            return (IIncomeDetail)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.IncomeDetailDAL);
        }

        /// <summary>
        /// 创建收入类型接口实例
        /// </summary>
        /// <returns></returns>
        public static IIncomeType CreateIncomeType()
        {
            return (IIncomeType)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.IncomeTypeDAL);
        }

        /// <summary>
        /// 创建日志接口实例
        /// </summary>
        /// <returns></returns>
        public static ILog CreateLog()
        {
            return (ILog)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.LogDAL);
        }

        /// <summary>
        /// 创建用户接口实例
        /// </summary>
        /// <returns></returns>
        public static IUser CreateUser()
        {
            return (IUser)Assembly.Load(ConfigHelper.RootDAL).CreateInstance(ConfigHelper.RootDAL + "." + ConfigHelper.UserDAL);
        }
    }
}
